#ifndef _CKCRAWLERWORK_H_
#define _CKCRAWLERWORK_H_



#include <string>
#include <vector>
#include "CKDatabase.h"

class CKCrawlerWork
{
private:
	K_Engine::CKDatabase m_db;

private:
	//域名表
	std::string m_strDomain;
	std::string m_strIp;
	bool m_bHasRobots;
	std::string m_strDisablePath;
	bool m_bDomainTurth;
	
	//路径表
	std::string m_strPath;
	std::string m_strUpdateTime;
	bool m_bPathTurth;
	
	//页面表
	std::string m_strParams;
	std::string m_strTitle;
	std::string m_strRequestCode;
	

private:
	std::vector<std::string> m_vecResultURL;

public:
	CKCrawlerWork(std::string init);
	std::string DoingWork(std::string strOtherParams);

private:
	void GetAndFormatHttptoHtml(std::string &strHtml);
	void ParserHTML(const std::string &strHtml);
	void ParserTitle(const std::string &strHead);
	void ParserBody(const std::string &strBody);
	bool CheckDomain(const std::string &strURL);
	std::string ParserURL(const std::string &strURL);
	std::string ParserDomain(const std::string &strURL);
	std::string ParserIP(const std::string &strURL);
	std::string ParserPath(const std::string &strURL);
	std::string ParserParams(const std::string &strURL);
	
private:
	bool InitDatabase(std::string strParams);
	bool CheckDBValueIsExistsOrAllowWork();
	void DealMessageForDatabase();
	std::string GetHostByName(const std::string name);
};


#endif // ! _CKCRAWLERWORK_H_
